package com.yzh.oop2;

public class Calculator {
    //成员变量
    String brand;
    int size;


    //成员方法
    public int  add(int num1,int num2){
       int result;
       result = num1+ num2;
       return result;
    }

    //减
    public int subtract(int num1,int num2){
        return num1 - num2 ;
    }

    public void introduce(){
        System.out.println("brand="+brand+",size="+size);
    }

    public static void main(String[] args) {

        Calculator calc1 = new Calculator();
        calc1.brand ="联想";
        calc1.size = 3;
        int n1=10;
        int n2 = 30;
        int sum = calc1.add(n1,n2);
        System.out.println("sum="+sum);
        calc1.introduce();

        Calculator calc2 = new Calculator();
        calc2.brand = "海尔";
        calc2.size = 5;
        int result = calc2.add(100,40);
        System.out.println(result);
        calc2.introduce();
    }
}
